//
//  CustomBuylistCell.m
//  忘不了
//
//  Created by rimi on 16/7/12.
//  Copyright © 2016年 handuan. All rights reserved.
//

#import "CustomBuylistCell.h"
#import "SDAutoLayout.h"
@implementation CustomBuylistCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeUserInterface];
    }
    return self;
}
- (void)initializeUserInterface{
    //colorView
    self.colorView = [[UIView alloc]init];
    self.colorView.layer.masksToBounds = YES;
    self.colorView.layer.cornerRadius = 12;
    [self.contentView addSubview:self.colorView];
    self.colorView.sd_layout
    .topSpaceToView(self.contentView,10)
    .leftSpaceToView(self.contentView,5)
    .bottomSpaceToView(self.contentView,10)
    .widthIs(24);
    
    //name
    self.name = [[UILabel alloc]init];
    [self.contentView addSubview:self.name];
    self.name.sd_layout
    .topSpaceToView(self.contentView,0)
    .leftSpaceToView(self.colorView,15)
    .bottomSpaceToView(self.contentView,0)
    .widthIs(CGRectGetWidth(self.contentView.bounds) * 0.7);
    
    //deleteButton
    self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.deleteButton addTarget: self action:@selector(delete) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.deleteButton];
    self.deleteButton.sd_layout
    .topSpaceToView(self.contentView,5)
    .rightSpaceToView(self.contentView,20)
    .bottomSpaceToView(self.contentView,5)
    .widthIs(34);
}
- (void)delete{
    if (self.delegate && [self.delegate respondsToSelector:@selector(customBuylistDelegate:)]) {
        [self.delegate customBuylistDelegate:self];
    }
}
@end
